<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form onsubmit="return fn()">
    <input id="username" type="text"/>
    <input id="password" type="text"/>
    <input id="submit" type="submit"/>
    <input id="reset" type="reset"/>
</form>

</body>
<script type="module" src="../static/main.js"></script>
<script>

    // 父类有加法方法
    class Father {
        constructor(x, y) {
            this.x = x;
            this.y = y;
        }
        sum() {
            console.log(this.x + this.y);
        }
    }

    class Son extends Father {
        constructor(a,b) {
            super(a,b);
            this.a= a;
            this.b = b
        }
        sub() {
            console.log(this.b-this.a)
        }
    }

    var son = new Son(1,2);
    son.sum()
    son.sub()



    class Star{
        // 构造函数
        constructor(name,age) {
            this.name = name
            this.age = age
        }
        eat() {
            alert("123")
        }
    }
    var star = new Star("li",9);
    console.log(star)

    let name = "zhangsan"
    let age  =18
    let stu = {
        name,
        age,
        eat: function () {

        },
        eat1:()=>{},
        eat2() {

        },


    }
    console.log(stu)
    // stu.name = name
    // stu.age = age

    // console.log(Object.keys(stu))
    // console.log(Object.values(stu))
    // console.log(Object.entries(stu))

    let target =  {a:1}
    let source1 = {b:2}
    let source2 = {a:4,c:3}
    // 合并
    // let assign = Object.assign(source2,source1,target);
    let assign = {...source2,...source1,...target}
    // console.info(assign)






    let map = new Map([['name','张三'],[{name:'jack'},{height:175, sex:'男' }]]);
    let obj = {};
    map.forEach((item, key) => {
        if(typeof key != 'string'){
            key = JSON.stringify(key);
        }
        obj[key] = item;
    });
    // console.log(obj)

    // let map = new Map([['name','jack'],['age',18]]);
    // map.forEach((a,b)=>console.log(b))
    //
    // var set = new Set([1,2,2,2]);
    // console.log(set)
    // set.forEach(item=>console.log(item))


    // let name = "lisi" +
    //     "sdf" +
    //     "dfsd"
    // let str = `名字叫${name}
    // 12231
    // sdf`
    // console.log(str)

    let ary = [{
        id: 1,
        name: '张三'
    }, {
        id: 2,
        name: '李四'
    }];
    // let target = ary.find((item) =>item.name==="张三")
    // console.log(target)


    let oDivs = document.getElementsByTagName('input');
    // console.log(oDivs)
    oDivs = [...oDivs];
    // console.log(oDivs)
    let a11 = [1,2,3]
    // console.log(...a11)
    // console.log(1,2,3)
    function f1(a,...b) {
        // console.log(a)
        // console.log(b)
    }
    f1(1,2,3,4)

    // var age = 100;
    // var obj = {
    //     age: 20,
    //     say: function () {
    //         alert(this.age)
    //     }
    // }
    // obj.say()
    //
    // const obj = {
    //     name1 :'lisi',
    //     age:18,
    //     eat: function () {
    //         console.log(this)
    //     },
    // }
    // obj.eat()

    function fn(a,b=1) {
        console.log(a+b)
        console.log(this)
        return ()=>{
            console.log(this)
        }
    }
    // var fn2 = fn.call(obj)
    // fn2()

    const fn1= (a)=> { return a}

    var sum = fn1(1,2);
    // console.log(sum)


    // const a = "lis"
    const arr1 = [1,2,3]
    // arr1 = [4,5,6]
    // arr1[0] = 4
    // arr1[1] = 5
    // arr1[2] = 6

    // 素组解构
    let [f,s,t,d] = arr1
    // console.log(f)
    // console.log(s)
    // console.log(t)
    // console.log(d)
    // console.log(arr1)

    // obj.name= "zhsngsan"
    // 对象解构
    // let {age:a,name1:n,aa} = obj
    // console.log(a)
    // console.log(n)
    // console.log(aa)


    var arr = [];
    for (let i = 0; i < 2; i++) {
        arr[i] = function () {
            console.log(i);
        }
    }
    // arr[0](); // 2  0
    // arr[1](); //2 1




    // console.log(a)
    // var a = 10
    // if (true) {
    //     // console.log(b)
    //     let b = 1;
    //     var c = 1;
    //     var c = 2;
    // }
    // console.log(c)




    // function fn() {
    //     var username = document.getElementById("username");
    //     var value = username.value;
    //     if (!new RegExp('/^[0-9]{4,8}$/').test(value)) {
    //         alert("用户名不能为空")
    //         username.onfocus
    //         return false;
    //     }
    //
    // }
</script>

</html>